local hengjiang = fk.CreateSkill{
  name = "iberia__hengjiang"
}

Fk:loadTranslationTable{
  ["iberia__hengjiang"] = "横江",
  [":iberia__hengjiang"] = "当你造成或受到伤害后，你可以令当前回合角色的手牌上限-1直到回合结束。"
  .."若如此做，且其手牌上限小于当前回合弃牌区的牌数，你摸一张牌。",
  ["#iberia__hengjiang-ivk"] = "横江：可以令 %src 的手牌上限-1直到回合结束<br/>然后若其手牌上限小于当前回合弃牌区的牌数，你摸一张牌"
}

local I = require "packages/iberia/utility"

local hengjiang_effect = {
  anim_type = "masochism",
  can_trigger = function (self, event, target, player, data)
    return player:hasSkill(hengjiang.name) and player == target and player.room.current:getMaxCards() > 0
  end,
  on_cost = function (self, event, target, player, data)
    local room = player.room
    return room:askToSkillInvoke(player, {
      skill_name = hengjiang.name,
      prompt = "#iberia__hengjiang-ivk:"..room.current.id
    })
  end,
  on_use = function (self, event, target, player, data)
    local room = player.room
    room:addPlayerMark(room.current, MarkEnum.MinusMaxCardsInTurn)
    if player.dead then return end
    if room.current:getMaxCards() < #S.getDisArea(room) then
      player:drawCards(1, hengjiang.name)
    end
  end,
}

hengjiang:addEffect(fk.Damaged, hengjiang_effect)
hengjiang:addEffect(fk.Damage, hengjiang_effect)

return hengjiang